import ajax from './ajax'
import mockAjax from './mockAjax'
//发送请求，获取三级列表数据
// export function reqCategoryListData(){
//     return ajax.get('/api/product/getBaseCategoryList')
// }

export const reqCategoryListData = () => {
    return ajax.get('/api/product/getBaseCategoryList')
}

//发送请求，获取banner轮播图的数据
export const reqBannerListData = () => {
    return mockAjax.get('/banner')
}

//发送请求，获取floor数据
export const reqFloorListData = () => {
    return mockAjax.get('/floor')
}

//发送请求，获取search页面的数据
export const reqSearchListData = (searchParams) => {
    // searchParams:{name:undefined,age:undefined,c:1}
    // searchParams:{name:'',age:'',c:1}
    return ajax.post('/api/list',searchParams)
}

//发送请求，根据传过去的skuId,获取detail商品详情页面的数据
export const reqDetailData = (id) => {
    return ajax.get(`/api/item/${id}`)
}

//发送请求，添加到购物车，对已有商品进行数量改动
export const reqAddToCart = (skuId,skuNum) => {
    return ajax.post(`/api/cart/addToCart/${ skuId }/${ skuNum }`)
}

//发送请求，获取购物车列表
export const reqShopCartListData = () => {
    return ajax.get('/api/cart/cartList')
}

//发送请求，切换商品选中状态，更新服务器中商品的isChecked
export const reqChangeShopCartInfo = (skuId,isChecked) => {
    return ajax.get(`/api/cart/checkCart/${skuId}/${isChecked}`)
}

//发送请求，删除购物车商品
export const reqDelShopCart = (skuId) => {
    return ajax.delete(`/api/cart/deleteCart/${skuId}`)
}

//发送请求，批量删除购物车商品
export const reqDelShopCartMany = (selectObj) => {
    return ajax.delete('/api/cart/batchDeleteCart',selectObj)
}









